package com.kgc.invitation.invitationmanagerweb.controller;

import com.kgc.invitation.bean.ReplyDetail;
import com.kgc.invitation.service.RepService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class RepController {

    @Reference
    RepService repService;
    @RequestMapping("/seleRep")
    public String seleRep(Integer id,
                          @RequestParam(value = "pageNum",required = false,defaultValue = "1")Integer pageNum){
        String repByinvid = repService.getRepByinvid(id, pageNum);
        return repByinvid;
    }

    @RequestMapping("/saveRep")
    public String saveRep(@RequestBody ReplyDetail replyDetail){
        replyDetail.setCreatedate(new Date());
        Integer addrep = repService.addrep(replyDetail);
        if(addrep>0){
            return "SUCCESS";
        }else{
            return "FAIL";
        }
    }


}
